package com.gca.airhockey;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.extension.physics.box2d.PhysicsConnector;
import org.anddev.andengine.extension.physics.box2d.PhysicsFactory;
import org.anddev.andengine.extension.physics.box2d.PhysicsWorld;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.Manifold;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.util.Log;

public class LED {
	private static final String LED_IMAGE_GREEN = "gfx/led_green.png";
	private static final String LED_IMAGE_RED = "gfx/led_red.png";
	private static final String LED_IMAGE_BW = "gfx/led_BW.png";
	

	private BitmapTextureAtlas mTexture;
	private TextureRegion mRegion;
	private Body mBody;
	private Sprite mSprite;

	public LED(Context pContext, Engine engine, EColor color, ESide pSide,int index) {
		this.mTexture = new BitmapTextureAtlas(32, 32,
				TextureOptions.BILINEAR_PREMULTIPLYALPHA);
		
		String fichierImage;
		
		switch (color) {
		case RED:
			fichierImage = LED_IMAGE_RED;
			break;
		case GREEN:
			fichierImage = LED_IMAGE_GREEN;
			break;
		case BW:
			fichierImage = LED_IMAGE_BW;
			break;
		default:
			fichierImage = LED_IMAGE_RED;
			break;
		}
		int posX;
		int posY = 10;
		if(pSide == ESide.LEFT)
			posX = 635+((index+1)*20);
		else
			posX = 615-((index+1)*20);
		
		this.mRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mTexture, pContext, fichierImage, 0, 0);
		engine.getTextureManager().loadTexture(this.mTexture);
		this.mSprite = new Sprite(posX, posY, mRegion);
		
		this.mSprite.setScale(0.5f);
		
	}
	
	public Sprite getSprite() {
		return mSprite;
	}
	public Body getBody() {
		return mBody;
	}

	
	
	}
